//
//  HexMapGeneratingStrategy.h
//  DiceWar
//
//  Created by Xiao  Feng on 17/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#ifndef GAME_GAMEPLAY_HEXMAPGENERATINGSTRATEGY_H_
#define GAME_GAMEPLAY_HEXMAPGENERATINGSTRATEGY_H_

#include "cocos2d.h"
#include "HexMapGrid.h"
#include "Player.h"

class HexMap;
class HexMapGeneratingStrategy
{
public:
    HexMapGeneratingStrategy();
    virtual ~HexMapGeneratingStrategy();
    
    void generate(int numPlayers, int numDicesPerplayer, HexMap& hexMap);
    
protected: 
    /** generate the position for all hex grids of given map
     */
    virtual void generateMapGridLocation(HexMap& hexMap) = 0;
    
    /** generate Player for all hex grids of given map
     */ 
    virtual void generateMapGridPlayer(int numPlayers, HexMap& hexMap) = 0;
    
    /** generate the number of dices in each cell for different players
     */
    virtual void generateMapGridNumDices(int numPlayers, int numDicesPerPlayer, HexMap& hexMap) = 0;
};

/** The normal strategy starts the grid (0, 0) from the left bottom conor of the screen
 */
class HexMapGeneratingStrategyNormal : public HexMapGeneratingStrategy
{
protected:
    virtual void generateMapGridLocation(HexMap& hexMap);
    virtual void generateMapGridPlayer(int numPlayers, HexMap& hexMap);
    virtual void generateMapGridNumDices(int numPlayers, int numDicesPerPlayer, HexMap& hexMap);
    
private:
    /** get the player type from a random number, the random number is in [0, numPlayers];
     if the random number is numPlayers, it is not owned by any player
     if the random number is in [0, numPlayers), it is owned by the corresponding player
     */
    PlayerType getPlayerType(int randomNum, int numPlayers);
};

#endif //GAME_GAMEPLAY_HEXMAPGENERATINGSTRATEGY_H_
